﻿Public Class uclogsetting
    Implements IConfHolder
    Private logsetting As ActivityLoggerConf
    Private slogsetting As ActivityLoggerConf
    Private logs As ActivityLogger
    Private verrors As String
    Public Function applyConfig() As Boolean Implements IConfHolder.applyConfig
        logsetting.logfolder = txtlogdirectory.Text
        logsetting.rotatelog = chkrotate.Checked
        If (Not logsetting.checkConfig) Then
            validationerrors = logsetting.validationerrors
            Return False
        End If
        logsetting.writeConfig()
        Return True
    End Function

    Public Sub forcewrite() Implements IConfHolder.forcewrite
        logsetting.writeConfig()
    End Sub

    Public Sub loadConfig() Implements IConfHolder.loadConfig
        logs = ActivityLogger.getInstance
        logsetting = New ActivityLoggerConf
        slogsetting = New ActivityLoggerConf
        displayConfig()
    End Sub
    Private Sub displayConfig()
        txtlogdirectory.Text = logsetting.logfolder
        chkrotate.Checked = logsetting.rotatelog
        txtcurrenlog.Text = logs.getCurrentLog
    End Sub
    Public Sub revertconfig() Implements IConfHolder.revertconfig
        logsetting.logfolder = slogsetting.logfolder
        logsetting.rotatelog = slogsetting.rotatelog
        displayConfig()
    End Sub


    Private Sub btnfolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfolder.Click
        fdb.ShowDialog()
        txtlogdirectory.Text = fdb.SelectedPath
    End Sub

    Public Property validationerrors As String Implements IConfHolder.validationerrors
        Get
            Return verrors
        End Get
        Set(ByVal value As String)
            verrors = value
        End Set
    End Property
End Class
